package com.styletransfer.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 阿里云OSS配置类
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "aliyun.oss")
public class AliyunOssConfig {
    /**
     * OSS服务的Endpoint
     */
    private String endpoint;
    
    /**
     * 访问密钥AccessKeyId
     */
    private String accessKeyId;
    
    /**
     * 访问密钥AccessKeySecret
     */
    private String accessKeySecret;
    
    /**
     * 存储空间名称
     */
    private String bucketName;
    
    /**
     * 访问URL前缀
     */
    private String urlPrefix;
    
    /**
     * 存储目录配置
     */
    private Dir dir = new Dir();
    
    /**
     * 创建OSS客户端实例
     */
    @Bean
    public OSS ossClient() {
        return new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
    }
    
    /**
     * 存储目录配置类
     */
    @Data
    public static class Dir {
        /**
         * 图片存储目录
         */
        private String image = "images/";
        
        /**
         * 风格图片存储目录
         */
        private String style = "styles/";
        
        /**
         * 生成结果存储目录
         */
        private String result = "results/";
    }
}
